﻿using MediatR;
using UserLicense.Applicationes.Command;
using UserModels;
using UserModels.DTO;
using UserRepositorys.Intface;

namespace UserLicense.Applicationes.CommandHandler
{
    public class AccountShowCommandHandler : IRequestHandler<AccountShowCommand, List<AccountRoleDTO>>
    {
        private readonly IAccountRepository accountRepository;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="accountRepository"></param>
        public AccountShowCommandHandler(IAccountRepository accountRepository)
        {
            this.accountRepository = accountRepository;
        }

        /// <summary>
        /// 查询所有账户信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        public async Task<List<AccountRoleDTO>> Handle(AccountShowCommand request, CancellationToken cancellationToken)
        {
            return await accountRepository.ShowAccount();
        }
    }
}
